package com.xbao.dao;

import com.xbao.model.PeriodRecord;
import com.xbao.model.req.RecordQuery;
import com.xbao.model.vo.PeriodRecordVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Created by qingshengzheng on 2019/1/28.
 */
@Mapper
public interface PeriodRecordExtraMapper {
    @Select("select * from period_record where cid=#{cid} and ontime>currenttime orderby ontime asc limit 1 ")
    public PeriodRecordVo nextPeriodRecordOfClss(Long cid,Long currenttime);

    @Select ("select count(1) from check where type=1 where createtime>#{beginTime} and createtime<#endTime and orgid=#{orgid}")
    public Integer shouldFinishCount(Long beginTime, Long endTime, Long orgid);

    @Select("select count(1) from check where type=2 where createtime>#{beginTime} and createtime<#{createtime} and orgid=#{orgid}")
    public Integer realFinishCount(Long beginTime, Long endTime, Long orgid);


    @Select("select * from period_reocrd as a left jon stu_record_rel as b on a.id=b.rid where b.sid=#{sid} and begintime>#{begintime} and endtime<#{endtime}")
    public List<PeriodRecord> queryHistoryPeriodOfStu(RecordQuery query);
    @Select("select count(1) from period_record where ruleid=#{rid} and status=0")
    public Integer getNoCheckPeriodCount(Long rid);

    @Select("select max(starttime) as starttime from period_record where ruleid=#{rid} and status=0")
    public Long selectMaxtimeByRuleId(Long rid);

}
